<template>
	<view class="content">
		<view class="title">单领优品小程序申请</view>
		<!-- <button class="btn color_green" open-type="getUserInfo" lang="zh_CN" @getuserinfo="onGotUserInfo">授权绑定微信手机号</button> -->
		<button class="btn color_green" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权绑定微信手机号</button>
		<checkbox class="checkBox" :value="isChecked" color="rgb(87,191,106)"  readonly="readonly" disabled="true" checked="true" @tap="tapCheckBox"/>
		<view class="chooseName">
			<view class="left">我已阅读并同意</view>
			<view class="right" @tap="btnAgree">《注册协议》</view>
		</view>
		
		
		<view class="shadowLogin" v-if="btnLogin">
			<view class="shadow_grey_logon" @tap="btnLogin = false"></view>
			<view class="shadow_white_logon">
				<image class="littleLogo" src="/static/index/logo.png" mode=""></image>
				<view class="littleName">单领优品小程序 申请</view>
				<view class="clearBoth"></view>
				<view class="littleNames">你的手机号码</view>
				<view class="infoBox">
					<view class="headImage overflow_one">{{tel}}</view>
					<view class="rights">
						<!-- <view class="userName overflow_one">20620606010</view> -->
						<view class="userNames overflow_one">微信绑定号码</view>
					</view>
					<!-- <image class="icon" src="../../../static/image/login/icon_1.png" mode=""></image> -->
					<view class="clearBoth"></view>
				</view>
				<view class="clearBoth"></view>
				<!-- <view class="otherName" @tap="btnUserOther">使用其他头像和昵称</view> -->
				<view class="btnBox">
					<view class="otherBtn color_grey"	@tap="btnFalse">拒绝</view>
					<view class="otherBtn color_green"	@tap="btnTrue">允许</view>
				</view>
			</view>
		</view>
		
	</view>
</template>
<style>
	.content{}
	.content .checkBox{margin-left: 5%;float: left;}
	.content .chooseName{margin-left:20upx;height:48upx;line-height: 48upx;float: left;}
	.content .chooseName .left{float: left;font-size: 15px;}
	.content .chooseName .right{float: left;font-size: 15px;color:rgb(87,191,106)}
	
	
	.content .title{font-weight: bold;width:90%;text-align: center;margin-left: 5%;color:#333333;font-size: 48upx;margin-top: 80upx;margin-bottom: 100upx;}
	.content .logoBox{width:100%;display: flex;justify-content: center;margin:100upx 0;margin-bottom: 300upx;}
	.content .logo{width:200upx;height:200upx;}
	.content .btn{width:90%;height:90upx;line-height: 90upx;margin-left: 5%;font-size: 16px;border-radius: 10upx;text-align: center;font-size:36upx;}
	.content .color_green{color:white;background: rgb(87,191,106);border:2upx solid rgb(87,191,106);margin:40upx 0;margin-left: 5%;}
	.content .color_black{color:#333333;background: white;border:2upx solid #ccc}
	.content .shadowLogin{width:100%;height:100%;position: fixed;top:0;left:0;z-index: 2;}
	.content .shadow_grey_logon{width:100%;height:100%;position: fixed;top:0;left:0;z-index: 3;background: rgba(0,0,0,0.4);}
	.content .shadow_white_logon{width:90%;padding:5%;height:40%;position: fixed;bottom:0;left:0;z-index: 4;background: white;border-top-left-radius: 30upx;border-top-right-radius:30upx;}
	.content .shadow_white_logon .littleLogo{width:44upx;height:44upx;float: left;margin-right: 20upx;}
	.content .shadow_white_logon .littleName{font-size: 26upx;height:44upx;line-height: 44upx;float: left;}
	.content .shadow_white_logon .littleNames{padding-bottom: 20upx;border-bottom: 2upx solid #ccc;font-size: 30upx;height:44upx;line-height: 44upx;margin:30upx 0 50upx 0;}
	.content .shadow_white_logon .infoBox{width:100%;}
	.content .shadow_white_logon .infoBox .headImage{width:40%;height:72upx;float: left;margin-right:20upx;}
	.content .shadow_white_logon .infoBox .icon{float: right;width:26upx;height:18upx;position: relative;top:12upx}
	.content .shadow_white_logon .infoBox .rights{width:40%;float:left}
	.content .shadow_white_logon .infoBox .rights .userName{width:100%;font-size: 28upx;}
	.content .shadow_white_logon .infoBox .rights .userNames{width:100%;font-size: 28upx;color:#666666;}
	.content .shadow_white_logon .otherName{color:#616684;font-size: 26upx;margin:40upx 0 60upx 0;}
	.content .shadow_white_logon .btnBox{width:70%;margin-left: 15%;display: flex;justify-content: center;margin-top: 120upx;}
	.content .shadow_white_logon .btnBox .otherBtn{width:45%;margin:0 2.5%;float: left;text-align: center;padding:10upx 0;border-radius: 10upx;}
	.content .shadow_white_logon .btnBox .color_grey{background-color: rgb(237,237,237);color:rgb(87,191,106);}
</style>
<script>
	var rawData, _that;
	import Share from '@/common/wx_share.js'
	export default {
		data() {
			return {
				share:{
					title:"",
					// path:'/pages/login/bindTel/bindTel',
					path:'/pages/tabbar/index',
					imageUrl:'',
					desc:'',
					content:''
				},
				nickName: '',
				avatarUrl: '',
				SessionKey: '',
				code:"",
				userInfo:[],
				isChecked:"1",
				btnLogin:false,
				tel:"",
				
				
				iv:"",
				encrypteData:"",
				session_keyData:"",
				userInfos:"",
				
				lastUserId:"",
			}
		},
		onLoad(e){
			this.share.path = this.share.path + "?userId=" + this._$userToken("userInfo").id
			// try {
			//     uni.setStorageSync('NewUserId', e.userId);
			// }catch(e){}
			this.AjaxLoad();
		},
		methods: {
			AjaxLoad(){
				var that = this;
				uni.getStorage({
				    key: 'encrypteData',
				    success: function (res) {
						that.encrypteData = res.data
				    }
				});
				uni.getStorage({
				    key: 'iv',
				    success: function (res) {
				        that.iv = res.data
				    }
				});
				uni.getStorage({
				    key: 'userInfo',
				    success: function (res) {
				        that.userInfos = res.data
				    }
				});
				uni.getStorage({
				    key: 'session_keyData',
				    success: function (res) {
				        that.session_keyData = res.data
				    }
				});
			},
			btnFalse(){
				uni.showToast({icon:"none",title:"已拒绝"})
				this.btnLogin = false
				setTimeout(function(){
					// uni.switchTab({url:"../../index/index"})
					// uni.navigateTo({
					// 	url:"../../index/index"
					// })
					uni.switchTab({
						url:"/pages/tabbar/index"
					})
				},1500)
			},
			btnAgree(){
				uni.navigateTo({
					url:"/pages_mine/pages/set_about_details/set_about_details?index=36&name=注册协议"
				})
			},
			tapCheckBox(){
				if( this.isChecked == "1" ){
					this.isChecked = "0"
				}else{
					this.isChecked = "1"
				}
			},
			btnTrue(){
				//pass
				uni.showToast({icon:"none",title:"登录成功"})
				setTimeout(function(){
					uni.switchTab({
						url:"/pages/tabbar/index"
					})
				},1500)
			},
			getPhoneNumber(e) {
				var that = this;
				try {
				    const value = uni.getStorageSync("NewUserId");
				    if (value) {
						that.lastUserId = value
				    }
				}catch(e){}
				let param={
					iv:e.detail.iv,
					encrypteData:e.detail.encryptedData,
					session_key:that.session_keyData,
					userInfo:JSON.stringify(that.userInfos),
					user_id:that.lastUserId,
				};
				that._$InitRequest.request('Login/get_phone', param).then(res => {
					try {
					    uni.setStorageSync('userInfo', res.data);
					}catch(e){}
					uni.showToast({icon:"none",title:"授权成功"})
					setTimeout(function(){
						uni.switchTab({
							url:"/pages/tabbar/index"
						})
					},1500)
				},error=>{})
			},
			// onGotUserInfo: function(e) {
			// 	var that = this;
			// 	if( this.isChecked == "1" ){
			// 		let param={
			// 			iv:that.iv,
			// 			encrypteData:that.encrypteData,
			// 			session_key:that.session_keyData,
			// 			userInfo:JSON.stringify(that.userInfos),
			// 		};
			// 		_that._$InitRequest.request('Login/get_phone', param).then(res => {
			// 			console.log( res );
						
						
			// 		},error=>{})
			// 	}else{
			// 		uni.showToast({
			// 			title: '请先同意用户协议',
			// 			icon: 'none'
			// 		});
			// 	}
			// },
		}
	}
</script>
<style lang="scss" scoped>
/deep/ .uni-input-input {font-size:32upx}
/deep/ .uni-radio-input-checked{background-color:rgb(110,43,34) !important;border:2upx solid white !important}
.content .html{
  ::v-deep {
    img {
      width: 100%;
    }
  }
}
</style>